package com.usian.behavior.controller


import com.baomidou.mybatisplus.core.toolkit.Wrappers
import com.usian.behavior.service.UnLikeBehaviorService
import com.usian.model.behavior.dtos.UnLikesBehaviorDto
import com.usian.model.behavior.pojos.ApUnlikesBehavior

import com.usian.model.common.dtos.ResponseResult
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/api/v1/behavior")
class UnLikeBehaviorController {
    @Autowired
    private val unlikeBehaviorService: UnLikeBehaviorService? = null

    @PostMapping("/unLike_behavior")
    fun unLike(@RequestBody dto: UnLikesBehaviorDto): ResponseResult<*> = unlikeBehaviorService!!.unLike(dto)


    @PostMapping("/getUnLike/{entryId}/{articleId}")
    fun getUnLike(@PathVariable entryId: Int, @PathVariable articleId: Long): ApUnlikesBehavior? {
        if (entryId === null || articleId === null) {
            println("参数不够")
            return null
        }
        return unlikeBehaviorService!!.getOne(Wrappers.query<ApUnlikesBehavior>().eq("article_id", articleId).eq("entry_id", entryId))
    }

}
